package com.winning.cjfw.service.controller;

import com.alibaba.fastjson.JSON;
import com.winning.cjfw.service.commons.CollectResponse;
import com.winning.cjfw.service.commons.JobExcuteReuest;
import com.winning.cjfw.service.service.CollectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Author: yanxf@winning.com.cn
 * Description: 采集接口控制层
 * Date 2019/5/24 19:51
 */

@RestController
@Slf4j
public class CollectController {

    @Resource
    private CollectService collectService;

    @RequestMapping("/collect")
    public String map(@RequestBody JobExcuteReuest jobExcuteReuest) {
        log.info( jobExcuteReuest.toString() );

        collectService.collectTables( jobExcuteReuest );


        CollectResponse collectResponse = new CollectResponse();
        collectResponse.setStatuscode( "200" );
        collectResponse.setRespmsg( "请求接收成功" );
        return JSON.toJSONString( collectResponse );
        /*HashMap hashMap = new LinkedHashMap();
        try {
            List<Map<String, Object>> list = iJdbcService.getPageList(tableName, 1, 10);
            hashMap.put("code", 200);
            hashMap.put("rows", list.size());
            hashMap.put(tableName, list);
        } catch (DataAccessException e) {
            log.error("查询表:{}失败，失败原因{}", tableName, e);
            hashMap.put("code", 500);
            hashMap.put("rows", null);
            hashMap.put(tableName, new ArrayList<>());
        } finally {

        }
        return hashMap;*/


       /* collectService.collectTables( "student" );*/
    }
}
